package com.pzh.guli.service.edu.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pzh.guli.service.base.result.Result;
import com.pzh.guli.service.edu.pojo.Test;
import com.pzh.guli.service.edu.service.ITestService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xzh
 * @since 2022-05-23
 */
@RestController

public class TestController {
    @Autowired
    private ITestService service;
    @RequestMapping("/test")
    public Result listAll(){
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.orderByDesc("sort");
        List<Test> list = service.list(queryWrapper);
        return Result.ok().data("item",list);
    }
    @PostMapping("insert")
    public Result insert(@RequestBody  Test test){
        service.save(test);
        return Result.ok().message("INSERT OK");
    }
    @GetMapping("sentinel")
    @SentinelResource("/test1")
    public Result test(){
        return Result.ok().message("I AM A SENTINEL TEST");
    }
}

